package com.shujia.mr.output;


import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.mapreduce.RecordWriter;
import org.apache.hadoop.mapreduce.TaskAttemptContext;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;

public class MyOutPutFormat extends FileOutputFormat {

    // 实现该函数 而该函数需要返回 RecordWriter对象
    //      而RecordWriter类中存在write和close两个抽象函数
    //      如果想要实现 自定义输出 那么就需要自定义一个RecordWriter的子类返回
    @Override
    public RecordWriter getRecordWriter(TaskAttemptContext job) throws IOException, InterruptedException {

        Configuration configuration = job.getConfiguration();
        return new MyRecordWriter(configuration);
    }
}
